package com.qf.task;


import com.qf.entity.Annunciate;
import com.qf.mapper.AnnounceDao;
import com.qf.utils.CompareTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.*;


@Component
@Slf4j
public class OATask {


    @Autowired
    private AnnounceDao announceDao;

    @Scheduled(cron = "0 */5 * * * ?")
    public  void findNotActiveOverThreeDays(){
        System.out.println("任务调度开始执行");
        Map map = new HashMap<>();
        map.put("annName","");
        map.put("publishTimeBegin", "");
        map.put("publishTimeOver", "");
        List<Annunciate> allAnnunciate = announceDao.findAllAnnunciate(map);
        if(allAnnunciate.size()==0){
            return;
        }
        for (Annunciate annunciate : allAnnunciate) {
            Map compare = CompareTime.compare(new Date(), annunciate);
            announceDao.updataStatus(compare);
        }
        System.out.println("任务调度执行完了");
    }
}
